package com.hongyi.service.Impl;

import com.hongyi.daomain.Emp;
import com.hongyi.mapper.EmpMapper;
import com.hongyi.query.PageQuery;
import com.hongyi.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hongyi
 * @date 2023/11/4 15:14
 */
@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpMapper empMapper;
    @Override
    public int getCount(String name, Integer minAge, Integer maxAge) {
        return empMapper.getCount(name, minAge, maxAge);
    }

    @Override
    public List<Emp> getPage_Tiaojian(Integer page, Integer rows, String name, Integer minAge, Integer maxAge) {
        // 注意: 计算标的其实位置(page - 1) * rows
        return empMapper.getPage_Tiaojian((page - 1) * rows, rows, name, minAge, maxAge);
    }

    @Override
    public List<Emp> getPage01(PageQuery pageQuery) {
        PageQuery pageQuery1 = new PageQuery((pageQuery.getPage() - 1) * pageQuery.getRows(), pageQuery.getRows());
        return empMapper.getPage01(pageQuery1);
    }
}
